#include <iostream>
#include <vector>
#include <ctime>
#include <algorithm>
using namespace std;
void quickSort(vector<int>&v,int L,int R)
{
	if (L > R)return;
	int left = L+1;
	int right = R;
	int pivot = v[L];
	while (left <= right)
	{
		while (left <= right && v[left] <= pivot)left++;
		while (left <= right && v[right] >= pivot)right--;
		if (left <= right)
		{
			swap(v[left], v[right]);
		}
	}
	swap(v[right], v[L]);
	quickSort(v, L, right - 1);
	quickSort(v, right + 1, R);
}
void Print(int val)
{
	cout << val << " ";
}
int main()
{
	vector<int>v;
	srand((unsigned int)time(NULL));
	for (int i = 0; i < 10; i++)
	{
		v.push_back(rand() % 50 + 12);
	}
	for_each(v.begin(), v.end(), Print);
	cout << endl;
	quickSort(v, 0, v.size() - 1);
	for_each(v.begin(), v.end(), Print);
}